import 'package:flutter/material.dart';

import './turn_box.dart';

class TurnBoxDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _TurnBoxDemoState();
  }
}

class _TurnBoxDemoState extends State<TurnBoxDemo> {
  double _turns = .0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('旋转容器的例子'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TurnBox(
              turns: _turns,
              speed: 500,
              child: Icon(Icons.refresh, size: 50,),
            ),
            TurnBox(
              turns: _turns,
              speed: 1000,
              child: Icon(Icons.refresh, size: 150,),
            ),
            RaisedButton(
              child: Text("顺时针旋转1/5圈"),
              onPressed: () {
                setState(() {
                  _turns += .2;
                });
              },
            ),
            RaisedButton(
              child: Text("逆时针旋转1/5圈"),
              onPressed: () {
                setState(() {
                  _turns -= .2;
                });
              },
            ),
          ].map((e) {
            return Padding(
              padding: EdgeInsets.all(16),
              child: e,
            );
          }).toList(),
        ),
      ),
    );
  }
}